package com.manli.api.controller;

import java.util.Arrays;
import java.util.Map;

import com.manli.api.pojo.QueryParamsMajorType;
import com.manli.api.pojo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import com.manli.api.base.annotation.Permissions;
import com.manli.api.pojo.QueryParams;
import com.manli.api.dto.MajorType;
import com.manli.api.service.MajorTypeService;



/**
 * 商店主营类别
 *
 * @author manli
 * @email 
 * @date 2020-05-15 13:13:01
 */
@Api(value="/majortype", tags="商店主营类别")
@RestController
@RequestMapping("api/majortype")
public class MajorTypeController {
    @Autowired
    private MajorTypeService majorTypeService;

    /**
     * 列表
     */
    @ApiOperation(value = "商店主营类别列表",notes = "get方式，请求参数直接跟url后面，如?page=1&limit=10")
    @PostMapping("/list")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_LOGIN)
    public Result list(@RequestBody QueryParamsMajorType params){
        return majorTypeService.queryPage(params);
    }

    /**
     * 全部数据信息
     */
    @ApiOperation(value = "商店主营类别全部数据信息",notes = "get方式，查询全部数据")
    @PostMapping("/all")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_LOGIN)
    public Result all(){
        return majorTypeService.queryAll();
    }

    /**
     * 单条信息
     */
    @ApiOperation(value = "商店主营类别单条信息",notes = "商店主营类别单条信息")
    @GetMapping("/info/{majorTypeId}")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_LOGIN)
    public Result info(@PathVariable("majorTypeId") Integer majorTypeId){
        return majorTypeService.getById(majorTypeId);
    }

    /**
     * 保存
     */
    @ApiOperation(value = "商店主营类别保存",notes = "商店主营类别保存")
    @PostMapping("/save")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_LOGIN)
    public Result save(@RequestBody MajorType majorType){
        return majorTypeService.save(majorType);
    }

    /**
     * 修改
     */
    @ApiOperation(value = "商店主营类别修改",notes = "商店主营类别修改")
    @PostMapping("/update")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_LOGIN)
    public Result update(@RequestBody MajorType majorType){
        return majorTypeService.updateById(majorType);
    }

    /**
     * 删除单条数据
     */
    @ApiOperation(value = "商店主营类别删除",notes = "商店主营类别删除")
    @ApiImplicitParam(name = "majorTypeIds", value = "id",dataType = "int", required = true)
    @PostMapping("/delete")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_LOGIN)
    public Result delete(Integer majorTypeId){
        return majorTypeService.removeById(majorTypeId);
    }

    /**
     * 删除多条数据
     */
    @ApiOperation(value = "商店主营类别删除",notes = "商店主营类别删除")
    @ApiImplicitParam(name = "majorTypeIds", value = "id数组,json字符串",dataType = "id数组,json字符串", required = true)
    @PostMapping("/deleteIds")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_LOGIN)
    public Result deleteIds(@RequestBody Integer[] majorTypeIds){
        return majorTypeService.removeByIds(Arrays.asList(majorTypeIds));
    }

}
